#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "BalanceTree.h"
using namespace std;
int main(){
    int N;
    cout<<"Enter a number which is less than 100: " ; //to restrict that the array is not too large
    cin>>N;
    int a[N];       //an array for storing the elements
    if(N>=100){     //an example for restriction, it can be altered by suitably large number
        cout<<"Error";
        return 0;
    }
    else{
        cout<<"Enter the elements of the array: ";
        for(int i=0;i<N;i++){
            a[i]=rand();    //to make sure all elements are randomised
        }
        cout<<"The array is: ";
        for(int i=0;i<N;i++){
            cout<<a[i]<<" ";    //show the array
        }
        cout<<endl;
    }
    
    AvlTree<int> T1;
    for(int i=0;i<N;i++){
        T1.insert(a[i]);
    }
    clock_t start1,end1;        //starting time and ending time
    double _start1,_end1;       //to record the starting and ending time
    start1=clock();
    T1.printTree();
    end1=clock();
    _start1=start1;
    _end1=end1;
    cout<<"The time used in AVL tree is "<<_end1-_start1<<endl;     //print out the time interval
    
    SplayTree<int> T2;
    for(int i=0;i<N;i++){
        T2.insert(a[i]);
    }
    clock_t start2,end2;        //same as above
    double _start2,_end2;
    start2=clock();
    T2.printTree();
    end2=clock();
    _start2=start2;
    _end2=end2;
    cout<<"The time used in Splay tree is "<<_end2-_start2<<endl;
    
}